﻿using System.Runtime.InteropServices;
using System.Windows.Input;

namespace DesktopToyWpf;

public static class Utils
{
    // 定义 Windows 消息常量
    private const int WM_SYSCOMMAND = 0x0112;
    private const int SC_SIZE = 0xF000;
    public const int WMSZ_LEFT = 1;
    public const int WMSZ_RIGHT = 2;
    public const int WMSZ_TOP = 3;
    public const int WMSZ_BOTTOM = 6;
    
    [DllImport("user32.dll", CharSet = CharSet.Auto)]
    private static extern IntPtr SendMessage(IntPtr hWnd, int Msg, IntPtr wParam, IntPtr lParam);

    public static void ResizeWindow(IntPtr hWnd, int direction)
    {
        SendMessage(hWnd, WM_SYSCOMMAND, SC_SIZE | direction, IntPtr.Zero);
    }

    
    public const uint SWP_NOSIZE = 0x0001;        // 不改变窗口大小
    public const uint SWP_NOMOVE = 0x0002;        // 不改变窗口位置
    public const uint SWP_NOZORDER = 0x0004;      // 不改变 Z 顺序
    public const uint SWP_NOREDRAW = 0x0008;      // 不重绘窗口
    public const uint SWP_NOACTIVATE = 0x0010;    // 不激活窗口
    public const uint SWP_FRAMECHANGED = 0x0020;  // 强制重绘非客户区
    public const uint SWP_SHOWWINDOW = 0x0040;    // 显示窗口
    public const uint SWP_HIDEWINDOW = 0x0080;    // 隐藏窗口
    public const uint SWP_NOCOPYBITS = 0x0100;    // 不复制原窗口内容
    public const uint SWP_NOOWNERZORDER = 0x0200; // 不改变所有者窗口 Z 顺序
    public const uint SWP_NOSENDCHANGING = 0x0400; // 不发送 WM_WINDOWPOSCHANGING 消息
    
    [DllImport("user32.dll", SetLastError = true)]
    public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int x, int y, int cx, int cy, uint uFlags);



   
}